package com.gege.homework10;

import com.gege.homework10.model.User;
import com.gege.homework10.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

/**
 * 配置 Hikari 连接池，改进上述操作
 *
 * @author gechenpeng
 * @date 2021-04-21
 */
public class DataSourceDemo {

    public static void main(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("applicationContext-homework10.xml");

        UserService userService = context.getBean(UserService.class);

        List<User> userList = new ArrayList<>();
        for (int i = 1; i <= 5; i++) {
            userList.add(User.builder()
                    .id("2021042121" + i)
                    .nickname("name" + i)
                    .build());
        }
        userService.addUserInBulk(userList);
    }
}
